/*
 * BinaryIndexedTree.h
 * This file is part of Jamming
 *
 * Copyright (C) 2012 - Yi
 *
 * Jamming is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * Jamming is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Jamming. If not, see <http://www.gnu.org/licenses/>.
 */


#ifndef __BINARYINDEXTREE_H__
#define __BINARYINDEXTREE_H__

namespace Tree {
    <template typename _TypeData,_TContainer=vector<_TypeData> >
    BinaryIndexTree : _TContainer {
        inline int lowbit(int idx) {
            return idx&(-idx);
        }
        vector<_TypeData> tree;
        public: 
        _TypeData cumulative(int idx) {
            _TContainer::
        }
        void update(int idx ,int val){
            while (idx <= MaxVal) {
                tree[idx] += val;
                idx += lowbit(idx);
            }
        }
    };
};

#endif /* __BINARYINDEXTREE_H__ */

